From a2772083e7efb2fc01a984a013df2b56571ba963 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Fri, 9 Dec 2022 00:15:57 +0100
Subject: [PATCH 2/3] scudo: clean up lingering weak symbols we don't want

---
 src/malloc/scudo/checksum.h   | 2 +-
 src/malloc/scudo/combined.h   | 2 +-
 src/malloc/scudo/crc32_hw.cpp | 4 ++++
 src/malloc/scudo/linux.cpp    | 5 +++++
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/malloc/scudo/checksum.h b/src/malloc/scudo/checksum.h
index f8eda81..d61b6d8 100644
--- a/src/malloc/scudo/checksum.h
+++ b/src/malloc/scudo/checksum.h
@@ -52,7 +52,7 @@ inline u16 computeBSDChecksum(u16 Sum, uptr Data) {
 }
 
 bool hasHardwareCRC32();
-WEAK u32 computeHardwareCRC32(u32 Crc, uptr Data);
+u32 computeHardwareCRC32(u32 Crc, uptr Data);
 
 } // namespace scudo
 
diff --git a/src/malloc/scudo/combined.h b/src/malloc/scudo/combined.h
index 365720d..e6609a8 100644
--- a/src/malloc/scudo/combined.h
+++ b/src/malloc/scudo/combined.h
@@ -137,7 +137,7 @@ public:
 
     // Check if hardware CRC32 is supported in the binary and by the platform,
     // if so, opt for the CRC32 hardware version of the checksum.
-    if (&computeHardwareCRC32 && hasHardwareCRC32())
+    if (hasHardwareCRC32())
       HashAlgorithm = Checksum::HardwareCRC32;
 
     if (UNLIKELY(!getRandom(&Cookie, sizeof(Cookie))))
diff --git a/src/malloc/scudo/crc32_hw.cpp b/src/malloc/scudo/crc32_hw.cpp
index 73f2ae0..4fe1693 100644
--- a/src/malloc/scudo/crc32_hw.cpp
+++ b/src/malloc/scudo/crc32_hw.cpp
@@ -14,6 +14,10 @@ namespace scudo {
 u32 computeHardwareCRC32(u32 Crc, uptr Data) {
   return static_cast<u32>(CRC32_INTRINSIC(Crc, Data));
 }
+#else
+u32 computeHardwareCRC32(u32, uptr) {
+    return 0;
+}
 #endif // defined(__CRC32__) || defined(__SSE4_2__) ||
        // defined(__ARM_FEATURE_CRC32)
 
diff --git a/src/malloc/scudo/linux.cpp b/src/malloc/scudo/linux.cpp
index 9c5755a..e79e8e8 100644
--- a/src/malloc/scudo/linux.cpp
+++ b/src/malloc/scudo/linux.cpp
@@ -177,9 +177,11 @@ bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
   return (ReadBytes == static_cast<ssize_t>(Length));
 }
 
+#if SCUDO_ANDROID
 // Allocation free syslog-like API.
 extern "C" WEAK int async_safe_write_log(int pri, const char *tag,
                                          const char *msg);
+#endif
 
 static uptr GetRSSFromBuffer(const char *Buf) {
   // The format of the file is:
@@ -214,6 +216,7 @@ uptr GetRSS() {
   return GetRSSFromBuffer(Buf);
 }
 
+#if SCUDO_ANDROID
 void outputRaw(const char *Buffer) {
   if (&async_safe_write_log) {
     constexpr s32 AndroidLogInfo = 4;
@@ -246,6 +249,10 @@ void setAbortMessage(const char *Message) {
   if (&android_set_abort_message)
     android_set_abort_message(Message);
 }
+#else
+void outputRaw(const char *) {}
+void setAbortMessage(const char *) {}
+#endif
 
 } // namespace scudo
 
-- 
2.38.1

